package net.siufung.security.base;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author 陈建峰
 * @date 2022/10/19 6:21 下午
 * @since V1.0.0
 */
@SuppressWarnings("deprecation")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class CurrentClient extends BaseClientDetails {

    private static final long serialVersionUID = -8849820074107997393L;

    public CurrentClient(String clientId, String clientSecret, Set<String> scope, Set<String> resourceIds,
                         Set<String> authorizedGrantTypes, Set<String> registeredRedirectUris,
                         Set<String> autoApproveScopes, List<GrantedAuthority> authorities,
                         Integer accessTokenValiditySeconds, Integer refreshTokenValiditySeconds,
                         Map<String, Object> additionalInformation){
        super.setClientId(clientId);
        super.setClientSecret(clientSecret);
        super.setScope(scope);
        super.setResourceIds(resourceIds);
        super.setAuthorizedGrantTypes(authorizedGrantTypes);
        super.setRegisteredRedirectUri(registeredRedirectUris);
        super.setAutoApproveScopes(autoApproveScopes);
        super.setAuthorities(authorities);
        super.setAccessTokenValiditySeconds(accessTokenValiditySeconds);
        super.setRefreshTokenValiditySeconds(refreshTokenValiditySeconds);
        super.setAdditionalInformation(additionalInformation);
    }

    public CurrentClient(String clientId, String clientSecret, Set<String> scope, Set<String> resourceIds,
                         Set<String> authorizedGrantTypes, Integer accessTokenValiditySeconds,
                         Integer refreshTokenValiditySeconds){
        super.setClientId(clientId);
        super.setClientSecret(clientSecret);
        super.setScope(scope);
        super.setResourceIds(resourceIds);
        super.setAuthorizedGrantTypes(authorizedGrantTypes);
        super.setAccessTokenValiditySeconds(accessTokenValiditySeconds);
        super.setRefreshTokenValiditySeconds(refreshTokenValiditySeconds);;
    }
}
